1 <?php
2  session_start();
3  
if(isset($_SESSION['user']))
4  {
5
6  }
7  
else{
8   echo
"<script>location.href='login.html'</script>";
9  }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14         <title>Customer </title>
15         <style>
16             body {
17   margin:
0;
18   font-family: Arial, Helvetica, sans-serif;
19   background: #
484848;
20 }
21 .topnav {
22   overflow: hidden;
23   background-color:#8d2663;
24   height: 70px;
25   border: 3px solid #b40a70;
26 }
27
28 .topnav a {
29   
float: left;
30   color: #f2f2f2;
31   text-align: center;
32   padding: 14px 16px;
33   text-decoration: none;
34   font-size: 35px;
35   font-weight: bold;
36 }
37
38 .topnav-right {
39   
float: right;
40 }
41 fieldset {
42   background: #FAFAFA;
43     padding: 10px;
44    margin:auto;
45    max-width:450px;
46     box-shadow: 1px 1px 25px rgba(
0, 0, 0, 0.35);
47     border-radius: 10px;
48     border: 6px solid #b40a70;
49
50
51 }
52
53
54 </style>
55 </head>
56 <body>
57 <div
class="topnav">
58             <a
class="active" href="home.html"><img src="ic_add_pet.png"></a>
59             <a href=
"customer.php">Customers</a>
60             <div
class="topnav-right">
61               <a href=
"logout.php">logout</a>
62             </div>
63           </div>
64    <form>
65        <button type=
"submit" formaction="customer.php" style="margin:15px;height: 30px;width: 100px;
66        border-radius:15px;
67 border: 3px solid #b40a70;background-color: #8d2663;color:#f2f2f2;font-size:15px;cursor:pointer;"
>back</button>
68 </form>
69 <form method=
"post" action="customeradd.php">
70 <fieldset>
71    <input type=
"text" name="id" placeholder="Enter the customer id" style="width:100%;height:30px;
72     border: 2px solid #b40a70; border-radius:5px; background:transparent;"
required>
73   <br><br>
74  <input type=
"text" name="fname" placeholder="Enter customer first_name" style="width:100%;height:30px;
75     border: 2px solid #b40a70; border-radius:5px; background:transparent;"
required>
76   <br><br>
77    <input type=
"text" name="minit" placeholder="Enter customer middle_name" style="width:100%;height:30px;
78     border: 2px solid #b40a70; border-radius:5px; background:transparent;"
required>
79   <br><br>
80    <input type=
"text" name="lname" placeholder="Enter customer last_name" style="width:100%;height:30px;
81     border: 2px solid #b40a70; border-radius:5px; background:transparent;"
required>
82   <br><br>
83   <input type=
"text" name="address" placeholder="Enter customer address" style="width:100%;height:30px;
84     border: 2px solid #b40a70; border-radius:5px; background:transparent;"
required>
85   <br><br>
86   <input type=
"submit" name="submit" value="ADD" style="width:100%;height:30px;
87     border: 2px solid #b40a70; border-radius:5px; cursor:pointer;background-color: #8d2663"
>
88   </fieldset>
89 </form>
90 </body>
91 </html>
92 <?php

93 if
(isset($_POST["submit"]))
94 {

95 // define variables and
set to empty values
96 $servername =
"localhost";
97 $username =
"root";
98 $password =
"";
99 $dbname =
"Petshop_management";
100
101 // Create connection

102 $conn =
new mysqli($servername, $username, $password, $dbname);
103 // Check connection

104 if
($conn->connect_error) {
105     die(
"Connection failed: " . $conn->connect_error);
106 }

107 //echo
" CONNECTION ESTABLISHED \r\n";
108 //echo
" INSERTION IN PROCESS";
109 $id = $_POST[
"id"];
110   $fname = $_POST[
"fname"];
111   $minit= $_POST[
"minit"];
112   $lname = $_POST[
"lname"];
113   $address = $_POST[
"address"];
114
115
116
117
118 $sql =
"INSERT INTO customer( cs_id,cs_fname,cs_minit,cs_lname,cs_address)
119 VALUES ('$id','$fname','$minit','$lname','$address')"
;
120 if
($conn->query($sql) == TRUE) {
121   echo
'<div>
122   <h1 style=
"color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of id='
123   .$id.
' inserted successfully</h1>
124      </div>
';
125 }
else {
126     echo
"Error: " . $sql . "<br>" . $conn->error;
127 }
128
129 $conn->close();
130 }
131 ?>


Gõ tìm kiếm nhanh...